import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter02/res/list_data.dart';

class MyHomePage extends StatelessWidget {
  MyHomePage({super.key}) {
    if (kDebugMode) {
      print(listData);
    }
  }

  List<Widget> _initListData() {
    List<Widget> tempList = [];
    for (var i = 0; i < listData.length; i++) {
      tempList.add(ListTile(
        leading: Image.network("${listData[i]['imageUrl']}"),
        title: Text("${listData[i]['title']}"),
        subtitle: Text("${listData[i]['author']}"),
      ));
    }
    return tempList;
  }

  @override
  Widget build(BuildContext context) {
    return ListView(children: _initListData());
  }
}
